﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FrameWork.Source.Animation_Classes;
using FrameWork.Source.Texture;
using FrameWork.Source.Resource_Manager;
using Boomer.Source.PathFinding;
using Microsoft.Xna.Framework;

namespace Boomer.Source.Character
{
    class CMob : CCharacter
    {
        private bool isFixedPos;
        protected bool isChangeDir;

        protected List<DIRECTION> listCantMoveDir;

        public CMob()
            : base()
        {
            this.Tag = FrameWork.Tag_Manager.TagManager.TAGGED.Enemy;
            isFixedPos = false;
            isChangeDir = true;
            listCantMoveDir = new List<DIRECTION>();
        }

        public override void init()
        {
            CAnimation[] pAnim;
            pAnim = new CAnimation[6];

            pAnim[0] = new CAnimation();
            pAnim[0].createAnimation("Stand", 0, 0, 0, 1.0f);
            pAnim[1] = new CAnimation();
            pAnim[1].createAnimation("Stand Animation", 1, 2, 1, 1.0f / 4.0f);
            pAnim[2] = new CAnimation();
            pAnim[2].createAnimation("Move Left", 3, 7, 3, 1.0f / 10.0f);
            pAnim[3] = new CAnimation();
            pAnim[3].createAnimation("Move Right", 8, 12, 8, 1.0f / 10.0f);
            pAnim[4] = new CAnimation();
            pAnim[4].createAnimation("Move Top", 13, 17, 13, 1.0f / 10.0f);
            pAnim[5] = new CAnimation();
            pAnim[5].createAnimation("Move Bot", 18, 22, 18, 1.0f / 10.0f);

            CTexture image = CResourceManager.getInstance().getImage((int)CResourceManager.IMG_MAIN.PLAYER);

            loadSprite(image, 23, 10, 66, 82, pAnim);
            createBoundBox(12.0f, 30.0f, 45, 30);

            
            base.init();
        }

        public override void update(float deltaTime)
        {
            base.update(deltaTime);
        }

        public override void draw()
        {
            base.draw();
        }

        public override bool Collision(ref global::FrameWork.Source.Object_Classes.CObject pObj)
        {
            return base.Collision(ref pObj);
        }

        public override void move(DIRECTION dir, float speed)
        {
            base.move(dir, speed);
        }

        protected void dying(float deltaTime)
        {
            this.getSprite().m_fAlpha -= 0.5f * deltaTime;
            if (this.getSprite().m_fAlpha <= 0)
            {
                this.m_isAlive = false;
            }
        }

        public void changeDir()
        {
            listCantMoveDir.Add( this.currDir );
            isChangeDir = true;
        }
    }
}
